using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Comdiv.Doc;
using Comdiv.Logging;
using Comdiv.Useful;
using Comdiv.Extensions;
namespace doctool
{
    public class Program
    {
        static void Main(string[] args)
        {
            logger.Manager = new TextWriterLogManager(false, true);
            var log = logger.get("doctool");
            string input = args.getArg("i", Environment.CurrentDirectory).mapPath();
            Console.WriteLine(args.getArg("i", Environment.CurrentDirectory));
            string output = args.getArg("o", Path.Combine(Environment.CurrentDirectory, "_docout")).mapPath();
            string views = args.getArg("v", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "dtdefault")).mapPath();
            string _includes = args.getArg("include", "");
            string _excludes = args.getArg("exclude", "");
            string[] includes = _includes.hasContent() ? _includes.Split(';') : new string[]{};
            string[] excludes = _excludes.hasContent() ? _excludes.Split(';') : new string[] { };



            
            var query = new DocumentQuery{
                                             InputDirectory = input,
                                             OutputDirectory = output,
                                             ViewDirectory = views,
                                             IncludePatterns = includes,
                                             ExcludePatterns = excludes
                                         };
            log.Info("start to process query"+Environment.NewLine+query);
            var generator = new DefaultDocumentGenerator();

            generator.Process(query);
            log.Info("finished");

        }
    }
}
